//
//  ViewController.m
//  26-GCD-皇儿版
//
//  Created by Snow on 16/8/18.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self createSerialQueue];
    [self createConCurrent];
}
- (void)createSerialQueue
{
    dispatch_queue_t queue = dispatch_queue_create("create serial_queue", DISPATCH_QUEUE_SERIAL);
    dispatch_async(queue, ^{
        NSLog(@"task1-begin");
        NSLog(@"task1-end");
    });
    dispatch_sync(queue, ^{
        NSLog(@"我是同步");
    });
    dispatch_async(queue, ^{
        NSLog(@"task2-begin");
        NSLog(@"task2-end");
    });
    dispatch_async(queue, ^{
        NSLog(@"task3-begin");
        NSLog(@"task3-end");
    });
}
- (void)createConCurrent
{
    dispatch_queue_t queue = dispatch_queue_create("create serial_queue", DISPATCH_QUEUE_CONCURRENT);
    dispatch_async(queue, ^{
        NSLog(@"task1-begin");
        NSLog(@"task1-end");
    });
    dispatch_sync(queue, ^{
        NSLog(@"我是同步");
    });

    dispatch_async(queue, ^{
        NSLog(@"task2-begin");
        NSLog(@"task2-end");
    });
    dispatch_async(queue, ^{
        NSLog(@"task3-begin");
        NSLog(@"task3-end");
    });
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
